using System;
using System.Collections.Generic;
using System.Text;
using AllegNet;

namespace DemonHunter
{
    /// <summary>
    /// levelBitmap index key: 
    ///     1-3 = skeleton run animation
    /// </summary>
    class Skeleton : Entity
    {
        //walk animation index
        private double currentAnimationIndex;

        private static List<Bmp> entityBitmaps;

        public Skeleton()
        {
            entityYLoc = 360;
            entityXLoc = Logic.GetInstance().GetXLoc() - entityBitmaps[0].Width;

            killable = true;
        }

        public override void animate()
        {
            //update animation to play
            currentAnimationIndex += (0.1 * speedModifier);

            if ((int)currentAnimationIndex > entityBitmaps.Count - 1)
            {
                CheckPlayerHit();
                currentAnimationIndex = 0;
            }
        }

        private void CheckPlayerHit()
        {
            PlayerCharacter player = PlayerCharacter.GetInstance();
            if (entityXLoc + entityBitmaps[0].Width >= player.getEntityXLoc() && entityXLoc + entityBitmaps[0].Width <= player.getEntityXLoc() + player.GetCurrentBitmap().Width)
                player.ReduceHealth(5);
        }

        public new static void LoadBitmaps()
        {
            entityBitmaps = new List<Bmp>();
            Game game = Game.GetInstance();
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\skeleton\\runSkele1.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\skeleton\\runSkele2.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\skeleton\\runSkele3.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\skeleton\\skeleAttack1.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\skeleton\\skeleAttack2.bmp"));
            entityBitmaps.Add(game.LoadBitmap("C:\\DemonHunterart\\enemy\\skeleton\\skeleAttack3.bmp"));
        }

        public override Bmp GetCurrentBitmap()
        {
            return entityBitmaps[(int)currentAnimationIndex];
        }

        public override double GetCurrentBitmapHeight()
        {
            return entityBitmaps[(int)currentAnimationIndex].Height;
        }
    }
}
